/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans.managed;

import beans.ejb.FantasyleagueFacade;
import entities.Fantasyleague;
import javax.ejb.EJB;
import javax.inject.Named;
import javax.enterprise.context.RequestScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

/**
 *
 * @author stumbledog
 */
@Named(value = "leagueSetting")
@RequestScoped
public class LeagueSetting {

    @EJB
    private FantasyleagueFacade fantasyleagueFacade;
    private Fantasyleague currentLeague;

    public Fantasyleague getCurrentLeague() {
        return currentLeague;
    }

    public void setCurrentLeague(Fantasyleague currentLeague) {
        this.currentLeague = currentLeague;
    }

    /**
     * Creates a new instance of LeagueSetting
     */
    public LeagueSetting() {
        FacesContext context = FacesContext.getCurrentInstance();
        HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest();
        AccountBean b = (AccountBean) request.getSession().getAttribute("accountBean");
        currentLeague = b.getCurrentLeague();
    }

    public String submit() {
        fantasyleagueFacade.edit(currentLeague);
        return "league";
    }

    public String cancel() {
        return "league";
    }
}
